/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vuze.rss.ui;

import org.gudy.azureus2.plugins.PluginInterface;
import org.gudy.azureus2.plugins.logging.LoggerChannel;
import org.gudy.azureus2.plugins.ui.config.ActionParameter;
import org.gudy.azureus2.plugins.ui.config.HyperlinkParameter;
import org.gudy.azureus2.plugins.ui.config.Parameter;
import org.gudy.azureus2.plugins.ui.config.ParameterListener;
import org.gudy.azureus2.plugins.ui.config.StringListParameter;
import org.gudy.azureus2.plugins.ui.model.BasicPluginConfigModel;

import vuze.rss.RssPlugin;


/**
 * UI class for configuration page
 *
 * @author rzb
 */
public class ConfigView
{
    private static ConfigView instance = null;
    private PluginInterface pluginInterface;
    private BasicPluginConfigModel configModel;
    private LoggerChannel logger;

    // Configuration controls
    StringListParameter algorithmList;
    ActionParameter testButton;
    HyperlinkParameter homePage;

    private ConfigView()
    {
        pluginInterface = RssPlugin.getPluginInterface();
        logger = RssPlugin.getLogger();

        initialize();
    }

    /**
     * Initialization of configure window
     *
     */
    private void initialize()
    {
        configModel = pluginInterface.getUIManager().
                            createBasicPluginConfigModel("plugin.configview.title");

        /*
         *
         *  Add configuration controls
         *  here !!
         *
         */
        // List of crypto algorithms
        algorithmList = configModel.addStringListParameter2("Algorithm",
                                        "plugin.configview.label.algorithm",
                                        new String[]
                                        {
                                            "Blowfish",
                                            "Twofish",
                                            "AES"
                                        },
                                        "AES");
        //
        testButton = configModel.addActionParameter2(null,
                                                     "plugin.configview.label.button");
        testButton.addListener(new ParameterListener()
        {
            public void parameterChanged(Parameter param)
            {
                testButton.setLabelText(algorithmList.getValue());
            }
        });

        // Add project's home page address
        homePage = configModel.addHyperlinkParameter2(
                                "plugin.configview.label.homepage",
                                "http://code.google.com/p/vuze-plugins/");

        // Add controls into box
        configModel.createGroup("plugin.configview.label.mainbox",
                new Parameter[] {algorithmList, testButton, homePage});







    }

    /**
     * Gets instance of plugin configuration page
     *
     * @return ConfigView
     *                      class instance
     */
    public static ConfigView getInstance()
    {
        if(instance != null)
        {
            return instance;
        }
        else
        {
            instance = new ConfigView();
            return instance;
        }
    }
    

}
